<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>05-v-if和v-for结合</title>
</head>
<body>

<div id="app">
  <ul v-if="shouldShowUsers">
    <li v-for="user in users" :key="user.id">
      {{ user.name }}
    </li>
  </ul>
</div>

<script src="../lib/vue.js"></script>
<script>
  let vm = new Vue({
    el: '#app',
    data: {
      users: [
        {
          id: 1,
          name: 'zhangsan',
          isActive: true
        },
        {
          id: 2,
          name: 'lisi',
          isActive: false
        }
      ]
    },
    computed: {
      activeUsers() {
        return this.users.filter(user => {
          return user.isActive
        })
      }
    }
  })
</script>


</body>
</html>